@extends('home.layout.base')
@section('scripts')
    <script>
        $(function () {
            $('.praise-btn').click(function(){
                let id = $(this).attr('data-id');
                let that = this;
                @if (auth()->guest())
                    window.location.href = "{{ route('home.auth.login') }}";
                @else
                    $.post("{{ route('home.new.praise') }}",{id:id,_token:"{{csrf_token()}}",},function(res){
                        if(res.code){
                            alert(res.msg);
                        }else{
                            $(that).children('em').text(res.data);
                        }
                    });
                @endif
            })
        })
    </script>
@endsection
@section('content')
    {{--new-info.png--}}
    <div class="main new-info">
        <div class="container">
            <div class="row">
                <div class="col-lg-12 new-info-head">
                    <p class="new-info-crumb"><a href="">首页</a> > <a href="{{ route('home.new.index') }}">新闻</a> > {{ $info['title'] }}</p>
                    <h4>{{ $info['title'] }}</h4>
                    <p class="new-info-other">{{ $info['user']['truename'] }}
                        <span>
                            {{ $info['created_at']->format('Y-m-d H:i') }} 发布在</span> {{ $info['cate']['name'] }} <span>
                            <i class="fa fa-eye"> &nbsp;{{ $info['view'] }}</i>
                        </span>
                    </p>
                </div>
            </div>
        </div>
    </div>
    <div class="container main">
        <div class="row">
            <div class="col-lg-9">
                <div class="new-info-detail">
                    {!! $info['content'] !!}
                    <div class="new-info-state">版权声明：本文未经授权发布，不代表链鸽立场，如若转载请联系原作者</div>
                    <div class="new-info-tags"><ul><li>文章标签：</li>
                            @if($info['tags'])
                                @foreach($info['tags'] as $k=>$tag)
                                    <li class="li-tag"><span>{{$tag['name']}}</span></li>
                                @endforeach
                            @endif
                        </ul>
                    </div>
                    <div class="new-info-next">
                        <button class="praise-btn" data-id="{{ $info['id'] }}">
                            <i class="fa fa-thumbs-o-up"></i> &nbsp;<em style="font-style: normal">{{ $info['praise'] }}</em>
                        </button>
                        <span>下一篇：
                            @if($next)
                                <a href="{{ route('home.new.info',['id'=>$next['id']]) }}">{{ str_limit($next['title'], 45) }}</a>
                            @else
                                这已经是最后一篇了
                            @endif
                        </span>
                    </div>
                </div>
                <div class="new-info-about">
                    <h4>相关资讯</h4>
                    @foreach($about_news as $key=>$news)
                        <div class="col-lg-4 about-item">
                            <a href="{{ route('home.new.info',['id'=>$news['id']]) }}">
                                <img src="{{ $news['thumb'] }}" alt="">
                                <div class="about-item-info">
                                    <p>{{ $news['title'] }}</p>
                                </div>
                            </a>
                        </div>
                    @endforeach
                </div>
            </div>
            <div class="col-lg-3 new-info-author">
                <div class="author-info">
                    <div class="author-head">
                        <a class="author-head-avatar" href="">
                            <img src="{{ $info['user']['avatar'] }}" alt="">
                        </a>
                        <div class="author-head-info">
                            <p>{{ $info['user']['truename'] }}</p>
                            <p>文章数：<span>{{ $total_news }}</span> &nbsp;&nbsp;浏览量：<span>{{ $total_views }}</span></p>
                        </div>
                    </div>
                    <div class="author-jian">
                        {{ $info['user']['introduce'] }}
                    </div>
                    <div class="author-art-list">
                        @foreach($user_news as $u=>$unews)
                            <p><i class="fa fa-circle"></i> <a href="{{ route('home.new.info',['id'=>$unews['id']]) }}">{{ $unews['title'] }}</a></p>
                        @endforeach
                    </div>
                    <a href="{{ route('home.column.info',['id'=>$info['author_id']]) }}" class="author-more">阅读作者更多文章 >></a>
                </div>
            </div>
        </div>
    </div>
@endsection

